package cn.itsource.ymcc.client.fallback;

import cn.itsource.ymcc.client.ESCourseFeignClient;
import cn.itsource.ymcc.doc.CourseDoc;
import cn.itsource.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class ESCourseFeignClientFallbackFactory implements FallbackFactory<ESCourseFeignClient> {
    @Override
    public ESCourseFeignClient create(Throwable throwable) {
        return new ESCourseFeignClient(){

            @Override
            public JSONResult addCourse(CourseDoc doc) {
                throwable.printStackTrace();
                return JSONResult.error("ES添加课程失败");
            }
        };
    }
}
